#ifndef PROFILER_GP2X_H
#define PROFILER_GP2X_H

#include "IProfiler.h"

#include <map>
using std::map;
#include <string>
using std::string;

#include <SDL.h>
//!Profiler for the GP2X
class CProfilerGP2X : public IProfiler
{
private:
	//!Structure to store the data about one function.
	struct timeStruct
	{
		//!Start time of execution of the function.
		Uint32 startTime;

		//!End time of execution of the function.
		Uint32 endTime;

		//!Total time of execution of the function.
		Uint32 executionTime;

		//!Number of time that the function has been executed.
		int numberOfExecution;
	};

	//!Map between the name of the functions and their data.
	map<string, timeStruct> m_timeMap;

	//!Execution data about the entire application.
	timeStruct m_allApplication;


public:
	//!Constructor.
	CProfilerGP2X(void);

	//!Destructor.
	~CProfilerGP2X(void);

	//!Initialisation of the profiler.
	/*!
	\return True if the initialisation succeeded. False if it failed.
	*/
	bool init(void);

	//!Start to get execution data for the application.
	void startApplication(void);

	//!Stop to get execution data for the entire application.
	void endApplication(void);

	//!Start to get execution data for a function.
	/*!
	\param name Name of the function. It doesn't need to be the exact name of the function. It is just a tag to represent 
	the function
	*/
	void startCount(const string& name);

	//!Stop to get execution data for a function.
	/*!
	\param name The name of the function to stop to get data from.
	*/
	void endCount(const string& name);

	//!Write the result in the console.
	void write(void);
};

#endif
